﻿using System;
using System.Runtime.Serialization;

namespace NetBay.Core.BusinessEntities.Workflow
{
    [DataContract]
    public class WorkflowCondition : ReturnObject
    {
        /// <summary>
        /// Get or set the identifier
        /// </summary>
        [DataMember]
        public long Identifier { get; set; }

        /// <summary>
        /// Class name
        /// </summary>
        [DataMember]
        public string ClassName { get; set; }

        /// <summary>
        /// Assembly name
        /// </summary>
        [DataMember]
        public string AssemblyName { get; set; }

        /// <summary>
        /// Get or set the name
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        /// <summary>
        /// Model description 
        /// </summary>
        [DataMember]
        public string Description { get; set; }

        /// <summary>
        /// Model description 
        /// </summary>
        [DataMember]
        public long ActionOrConditionId { get; set; }

        /// <summary>
        /// Model description 
        /// </summary>
        [DataMember]
        public bool IsTrigger { get; set; }

        #region Constructors
        
        public WorkflowCondition()
        {
            this.Key = Guid.NewGuid();
        }

        /// <summary>
        /// Only for error
        /// </summary>
        /// <param name="ErrorMessage"></param>
        public WorkflowCondition(string errorMessage, Exception applicationException = null)
        : base(errorMessage, applicationException)
        {
        }

        #endregion

        #region Public functions

        public override string ToString()
        {
            return string.Format("Identifier: {0}, ClassName: {1}, AssemblyName: {2}, Name: {3}, Description: {4}, IsTrigger: {5}", Identifier, ClassName, AssemblyName, Name, Description, IsTrigger);
        }

        /// <summary>
        /// Gets the full name of the type.
        /// </summary>
        /// <returns></returns>
        public string GetFullTypeName()
        {
            return string.Format("{0}.{1}", AssemblyName, ClassName);
        }

        #endregion


    }
}